const { ccclass, property } = cc._decorator;

@ccclass
export default class UiAdapter extends cc.Component {
  onLoad() {
    cc.view.enableAutoFullScreen(false);
    cc.macro.ENABLE_MULTI_TOUCH = false;
    let canvas = this.getComponent(cc.Canvas);
    if (canvas) {
      //根据屏幕分辨率修改适配
      const viewRect = cc.view.getViewportRect();
      const curScreeRate = viewRect.width / viewRect.height;
      const designRate = 640 / 960;
      if (curScreeRate > designRate) {
        canvas.fitHeight = true;
        canvas.fitWidth = false;
      } else {
        canvas.fitHeight = false;
        canvas.fitWidth = true;
      }
    }
  }
}
